package com.dkd.manage.domain;

import lombok.Data;
import org.dromara.autotable.annotation.*;
import org.dromara.autotable.annotation.enums.IndexTypeEnum;
import org.dromara.autotable.annotation.mysql.MysqlCharset;
import org.dromara.autotable.annotation.mysql.MysqlColumnZerofill;
import org.dromara.autotable.annotation.mysql.MysqlEngine;
import org.dromara.autotable.annotation.mysql.MysqlTypeConstant;

@Data
@Ignore  //忽略自动维护，优先级大于其他注解
@AutoTable(comment = "测试表") //声明表信息（默认表名使用类名转下划线test_table，通过value可以修改），激活表自动维护
@MysqlEngine( "InnoDB") //MySQL专属注解，指定表的引擎
@MysqlCharset(charset = "utf8", collate = "utf8_general_ci")
//用于实体声明多字段联合索引使用，fields和indexFields必须配置一个
//@TableIndex(name = "name_phone", type = IndexTypeEnum.UNIQUE, fields = {"username", "phone"}, comment = "姓名电话联合索引")
public class TestTable {

    @PrimaryKey(autoIncrement = true) //设置自增主键
    private Integer id;

    @AutoColumn("username") //列定义注解，聚合注解，可以指定列名，字段类型、长度、是否为空、默认值、字段顺序等
    @Index(name = "username", type = IndexTypeEnum.NORMAL, comment = "用户名索引")
    private String username;

    @ColumnName("age") //列名
    @ColumnNotNull //非空
    @ColumnType(value = MysqlTypeConstant.INT, length = 3) //列类型及长度
    @ColumnComment("年龄") //列注释
    @MysqlColumnZerofill //指定数据类型固定长度不足情况下，进行前置补零
    @ColumnDefault("0") //指定列的默认值
    private Integer age;

    private String phone;

}
